package com.zhl.media.app.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class Node implements Serializable {

    private String id;
    /**
     * 根节点pId为0
     */
    private String pId="0";

    private String name;
    // 总安装数
    private int sumNum;

    // 已安装数
    private int yiNum;

    // 设置调整
    private int sttzNum;
    // 已调整
    private int ytzNum;
    // 设置补画
    private int ssbhNum;
    // 空余媒体位数
    private int kymtwNum;
    // 项目ID
    private String projectId;
    //楼座ID
    private String buildingId;
    //单元ID
    private String unitId;
    //type
    private int type;
    /**
     * 当前的级别
     */
    private int level;

    /**
     * 是否展开
     */
    private boolean isExpand = false;

    private int icon;

    /**
     * 下一级的子Node
     */
    private List<Node> children = new ArrayList<Node>();

    /**
     * 父Node
     */
    private Node parent;

    public Node()
    {
    }

    public Node(String id, String pId, String name, int sumNum, int yiNum, int sttzNum, int ytzNum, int ssbhNum,int kymtwNum,int type,String projectId,String buildingId,String unitId) {
        super();
        this.id = id;
        this.pId = pId;
        this.name = name;
        this.sumNum = sumNum;
        this.yiNum = yiNum;
        this.sttzNum = sttzNum;
        this.ytzNum = ytzNum;
        this.ssbhNum = ssbhNum;
        this.kymtwNum = kymtwNum;
        this.type = type;
        this.projectId = projectId;
        this.buildingId = buildingId;
        this.unitId = unitId;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public int getSumNum() {
        return sumNum;
    }

    public void setSumNum(int sumNum) {
        this.sumNum = sumNum;
    }

    public int getYiNum() {
        return yiNum;
    }

    public void setYiNum(int yiNum) {
        this.yiNum = yiNum;
    }

    public int getSttzNum() {
        return sttzNum;
    }

    public void setSttzNum(int sttzNum) {
        this.sttzNum = sttzNum;
    }

    public int getYtzNum() {
        return ytzNum;
    }

    public void setYtzNum(int ytzNum) {
        this.ytzNum = ytzNum;
    }

    public int getSsbhNum() {
        return ssbhNum;
    }

    public void setSsbhNum(int ssbhNum) {
        this.ssbhNum = ssbhNum;
    }

    public int getKymtwNum() {
        return kymtwNum;
    }

    public void setKymtwNum(int kymtwNum) {
        this.kymtwNum = kymtwNum;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getIcon()
    {
        return icon;
    }

    public void setIcon(int icon)
    {
        this.icon = icon;
    }

    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
    }

    public String getpId()
    {
        return pId;
    }

    public void setpId(String pId)
    {
        this.pId = pId;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public void setLevel(int level)
    {
        this.level = level;
    }

    public boolean isExpand()
    {
        return isExpand;
    }

    public List<Node> getChildren()
    {
        return children;
    }

    public void setChildren(List<Node> children)
    {
        this.children = children;
    }

    public Node getParent()
    {
        return parent;
    }

    public void setParent(Node parent)
    {
        this.parent = parent;
    }

    /**
     * 是否为跟节点
     *
     * @return
     */
    public boolean isRoot()
    {
        return parent == null;
    }

    /**
     * 判断父节点是否展开
     *
     * @return
     */
    public boolean isParentExpand()
    {
        if (parent == null)
            return false;
        return parent.isExpand();
    }

    /**
     * 是否是叶子界点
     *
     * @return
     */
    public boolean isLeaf()
    {
        return children.size() == 0;
    }

    /**
     * 获取level
     */
    public int getLevel()
    {
        return parent == null ? 0 : parent.getLevel() + 1;
    }

    /**
     * 设置展开
     *
     * @param isExpand
     */
    public void setExpand(boolean isExpand)
    {
        this.isExpand = isExpand;
        if (!isExpand)
        {

            for (Node node : children)
            {
                node.setExpand(isExpand);
            }
        }
    }

    public String getBuildingId() {
        return buildingId;
    }

    public void setBuildingId(String buildingId) {
        this.buildingId = buildingId;
    }

    public String getUnitId() {
        return unitId;
    }

    public void setUnitId(String unitId) {
        this.unitId = unitId;
    }
}